package cn.lyq.card.ui.wallet

import android.widget.ImageView
import cn.lyq.card.R
import cn.lyq.card.data.model.BillInfo
import cn.lyq.card.manager.UserManager
import cn.lyq.card.utils.loadUrl
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder


class WalletAdapter : BaseQuickAdapter<BillInfo, BaseViewHolder>
    (R.layout.item_money_away, mutableListOf()), LoadMoreModule {

    override fun convert(holder: BaseViewHolder, item: BillInfo) {
        val typeInfo = UserManager.billTypeList[item.type]
        holder.getView<ImageView>(R.id.imgType).loadUrl(typeInfo?.typeImg ?: "")
        holder.setText(R.id.tvTypeName, typeInfo?.typeName ?: "")
            .setText(R.id.tvValue, item.price)
            .setText(R.id.tvTime, item.addTime)
            .setText(R.id.tvSn, item.posSn ?: "")
            .setText(R.id.tvRemark, item.msg ?: "")

            .setGone(R.id.tvSn, item.posSn?.isNotEmpty() != true)
            .setGone(R.id.tvSnHint, item.posSn?.isNotEmpty() != true)
            .setGone(R.id.tvRemark, item.msg?.isNotEmpty() != true)
            .setGone(R.id.tvRemarkHint, item.msg?.isNotEmpty() != true)
    }

}